class Solution {
public:
    typedef int LL;
    static const LL maxn=1e5+100;
    stack<LL>s;
    vector<LL>v;
    LL ans[maxn];
    vector<int> canSeePersonsCount(vector<int>& heights) {
        for(int i=heights.size()-1;i>=0;i--){
            while(!s.empty()&&heights[s.top()]<heights[i]) s.pop(),ans[i]++;
            if(!s.empty()) ans[i]++;
            s.push(i);
        }
        for(int i=0;i<heights.size();i++){
            v.push_back(ans[i]);
        }
        return v;
    }
};